#ifndef GLVIEWPORT_H
#define GLVIEWPORT_H

#include <QGLWidget>
#include <QList>
#include <QPoint>
#include "entitymodel.h"
#include "aed_entity.h"



class GLViewport : public QGLWidget
{
    Q_OBJECT
    QList<AED_Entity>* m_ents;
    QList<AED_Entity*> m_temp_ents;

    EntityModel *m_model;

    float m_zoom;
    float m_ratio;
    float m_cam_x;
    float m_cam_y;
    float m_width;
    float m_height;
    QPoint last_pos;
    QPoint m_scaling_point;

    float m_original_size;
    int m_state;
    bool m_snap;
    bool m_focused;
    bool m_shift;
    QPointF m_c;
    QPointF m_c2;
    float m_ox,m_oy;
    float m_alpha;


public:
    explicit GLViewport(QList<AED_Entity>* ents,EntityModel *model, QWidget *parent = 0);
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void focusInEvent(QFocusEvent *event);
    void focusOutEvent(QFocusEvent *event);
    QPointF Mouse2Screen(QPoint pos);
    void SelectEntity(float x, float y);
    void SelectEntityPlus(float x, float y);
    void SelectEntityBox(QPointF c1, QPointF c2);

signals:
    void EntityChanged(QModelIndex index);
    void UpdateView();
    void ArchtypeChanged(AED_Archtype *arch);
public slots:

};

#endif // GLVIEWPORT_H
